#include<iostream>
#include<map>
using namespace std;
const int N = 1e6 + 10;
typedef long long LL;
int arr[N];
int cnt[N];
LL s[N];
int n;
int main()
{
	cin >> n;
	LL ans = 0;
	cnt[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		s[i] = s[i - 1] + arr[i];
		for (int j = 0; j * j <= s[i]; j++) {
			ans += cnt[s[i] - j * j];
		}
		cnt[s[i]]++;
	}
	cout << ans << endl;
	return 0;
}
	